package cn.com.ddapp.ddm.ui;

import android.view.Gravity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import cn.com.ddapp.ddm.AppConfig;
import cn.com.ddapp.ddm.R;
import cn.com.ddapp.ddm.api.OKUtilAPI;
import cn.com.ddapp.ddm.base.BaseActivity;
import cn.com.ddapp.ddm.base.BaseApplication;
import cn.com.ddapp.ddm.bean.OrderEvlate;
import cn.com.ddapp.ddm.inter.OkUtilCallback;
import cn.com.ddapp.ddm.ui.empty.EmptyLayout;
import cn.com.ddapp.ddm.util.TLog;

/**
 * Created by caopenghui on 2016-08-14.
 */
public class TestActivity extends BaseActivity{

    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.action)
    TextView action;
    @BindView(R.id.listView)
    ListView listView;
    @BindView(R.id.error_layout)
    EmptyLayout mEmptyLayout;

    @Override
    public void initView() {
        title.setText(R.string.test);
        action.setVisibility(View.VISIBLE);
    }

    @Override
    public void initData() {
        reequestData();
    }

    private void reequestData() {
        mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
        Integer userId = 11;;
        final OkUtilCallback okUtilCallback = new OkUtilCallback(mEmptyLayout){
            @Override
            public void onMyResponse(String response, int id) {
//              hideWaitDialog();
                TLog.log(getFragmentTag(),response);
                OrderEvlate entity = gson.fromJson(response,OrderEvlate.class);
                if((!AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))&&entity.getLogin()){
                    mEmptyLayout.setErrorType(EmptyLayout.NO_LOGIN);
                }else if((!AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))){
                    BaseApplication.getIntstance().showToast(entity.getResult(), Toast.LENGTH_SHORT,0, Gravity.TOP);
                }else if((AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))){

                }
            }
        };
//        id=292
        OKUtilAPI.post(OKUtilAPI.evalList, "userId=" + userId+"&id="+292, okUtilCallback);
    }

    @Override
    public int getContentViewId() {
        return R.layout.test_activity;
    }


    @Override
    protected String getFragmentTag() {
        return TestActivity.class.getSimpleName();
    }
}
